<?php require_once('Connections/cnn.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  if (PHP_VERSION < 6) {
    $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
  }

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "formElem")) {
  $insertSQL = sprintf("INSERT INTO usuario (Usuario, Email, Password, Nombre, Apellido, Telefono) VALUES (%s, %s, %s, %s, %s, %s)",
                       GetSQLValueString($_POST['Usuario'], "text"),
                       GetSQLValueString($_POST['Email'], "text"),
                       GetSQLValueString($_POST['Password'], "text"),
                       GetSQLValueString($_POST['Nombre'], "text"),
                       GetSQLValueString($_POST['Apellido'], "text"),
                       GetSQLValueString($_POST['Telefono'], "int"));

  mysql_select_db($database_cnn, $cnn);
  $Result1 = mysql_query($insertSQL, $cnn) or die(mysql_error());

    $insertGoTo = "index.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}
?>
<!doctype html>
<html><!-- InstanceBegin template="/Templates/plantilla.dwt" codeOutsideHTMLIsLocked="false" -->
<head>
<meta charset="utf-8">
<!-- InstanceBeginEditable name="doctitle" -->
<title>Ventas</title>
<!-- InstanceEndEditable -->
<!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
<link href="css/estilo.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="css/style1.css" type="text/css" media="screen"/>
<link href="SpryAssets/SpryValidationTextField.css" rel="stylesheet" type="text/css">
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
        
    </head>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<!-- InstanceBeginEditable name="1" -->
  <!-- Skitter Styles -->


  
  <!-- Skitter JS -->
  <script type="text/javascript" language="javascript" src="js/jquery-1.6.3.min.js"></script>
 <script type="text/javascript" src="js/sliding.form.js"></script>
  <script type="text/javascript" language="javascript" src="js/menu.js"></script>
  <script src="SpryAssets/SpryValidationTextField.js" type="text/javascript"></script>
   


   

 

<![endif]-->


<!-- InstanceEndEditable -->
</head>


<body>


<div class="container">
  <header>
    <img src="images/banner.png" width="960" height="194" />

  </header>
    <ul class="menu">
            <li><a href="index.php">Home</a></li>
            <li><a href="Productos.php">Productos</a></li>
            <li><a href="#">Acerca</a></li>
            <li><a href="Contactenos.php">Contactanos</a></li>
        </ul>
 
   <br><br><br><br><br>

  <!-- InstanceBeginEditable name="2" -->
  <!--script del slider -->

  <!-- script del menu -->
   <script type="text/javascript">
            $(document).ready(function() {
                $('.menu').tagdrop({tagPaddingTop: '60px',bgColor: '#B1CCED',bgMoverColor: '#7FB0F0',textColor: '#e0e0e0'});
            });
        </script>

  <div id="content">
  <div id="wrapper">
                <div id="steps">
                    <form method="post" name="formElem" id="formElem" action="<?php echo $editFormAction; ?>">
                        <fieldset class="step">
                            <legend>Registro de Usuarios</legend>
                            <p>
                                <label for="username">Usuario</label>
                                <input id="username" name="Usuario" />
                            </p>
                            <p>
                                <label for="email">Email</label>
                                <span id="sprytextfield2">
                                <input id="email" name="Email" placeholder="datos@supergangas.com" type="text" AUTOCOMPLETE=OFF />
                                 <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">Formato no válido.</span></span>
                                
                            </p>
                            <p>
                                <label for="password">Contraseña</label>
                                <input id="password" name="Password" type="password" AUTOCOMPLETE=OFF />
                            </p>
                        </fieldset>
                        <fieldset class="step">
                            <legend>Informacion Personal</legend>
                            <p>
                                <label for="name">Nombres</label>
                                <input id="name" name="Nombre" type="text" AUTOCOMPLETE=OFF />
                            </p>
                            <p>
                                <label for="country">Apellidos</label>
                                <input id="country" name="Apellido" type="text" AUTOCOMPLETE=OFF />
                            </p>
                            <p>
                                <label for="phone">Telefono</label>
                               <span id="sprytextfield6">
        <input id="phone" name="Telefono" placeholder="2222-2222" type="tel" AUTOCOMPLETE=OFF />
        <span class="textfieldRequiredMsg">*</span><span class="textfieldInvalidFormatMsg">Formato no válido.</span></span>
                            </p>
                        </fieldset>
                        
            <fieldset class="step">
                            <legend>Confirmar</legend>
              <p>
               Verifique que todos los datos esten
               debidamente correctos antes de registrar.
              </p>
                            <p class="submit">
                                <button id="registerButton" type="submit">Registrarse</button>
                            </p>
                        </fieldset>
                        <input type="hidden" name="MM_insert" value="formElem">
  </form>
  <script  type="text/javascript">
  var sprytextfield2 = new Spry.Widget.ValidationTextField("sprytextfield2", "email");
  var sprytextfield6 = new Spry.Widget.ValidationTextField("sprytextfield6", "phone_number", {format:"phone_custom", pattern:"00000000", useCharacterMasking:true});
  </script>
                   
                </div>
                <div id="navigation" style="display:none;">
                    <ul>
                        <li class="selected">
                            <a href="#">Cuenta</a>
                        </li>
                        <li>
                            <a href="#">Informacion Personal</a>
                        </li>
                       
            <li>
                            <a href="#">Confirmar</a>
                        </li>
                    </ul>
                </div>
            </div>
         </div>         
  
   


  <footer>
    <h3>Super Gangas</h3>
  </footer>
  <!-- end .container --></div>

</body>
<!-- InstanceEnd --></html>
